<template>
    <el-dialog
      title="修改区域"
      :visible="Visible"
      width="630px"
      @close="closeFn"
    >
      <span>
        <el-form
          :model="newForm2"
          :rules="newRules"
          label-width="100px"
          class="demo-ruleForm"
          ref="newDom2"
        >
          <el-form-item label="区域名称：" prop="regionName">
            <el-input
              v-model="newForm2.regionName"
              autocomplete="off"

              maxlength="15"
              show-word-limit
            ></el-input>
          </el-form-item>
          <el-form-item label="备注说明：" prop="remark">
            <el-input
              v-model="newForm2.remark"
              type="textarea"

              autocomplete="off"
              maxlength="40"
              show-word-limit
            ></el-input>
          </el-form-item>
        </el-form>
      </span>
      <span slot="footer" class="dialog-footer">
        <el-button @click="closeFn" class="noBtn">取 消</el-button>
        <el-button type="primary" @click="submit" class="yesBtn">确 定</el-button>
      </span>
    </el-dialog>
</template>

<script>
// import { xgQy } from '@/api/dianweiguanli/quyu'
export default {
  props: {
    Visible: {
      type: Boolean,
      required: true
    },
    tableData: {
      type: Array,
      required: true
    }

  },
  data () {
    return {
      newForm2: {
        regionName: '',
        remark: ''
      },
      newRules: {
        regionName: [
          { required: true, message: '请输入区域名称', trigger: 'blur' },
          {
            min: 1,
            max: 15,
            message: '长度在 1 到 15 个字符',
            trigger: 'blur'
          }
          // {
          //   validator: (rule, value, callback) => {
          //     const isRepeat = this.tableData.some(item => item.regionName === value)
          //     isRepeat ? callback(new Error('区域名称重复')) : callback()
          //   },
          //   trigger: 'blur'
          // }
        ],
        remark: [
          { required: true, message: '请输入备注说明', trigger: 'blur' },
          {
            min: 1,
            max: 40,
            message: '长度在 1 到 40 个字符',
            trigger: 'blur'
          }
        ]
      }
    }
  },
  created () {},
  mounted () {},
  methods: {
    closeFn () {
      this.$emit('update:Visible', false)
      this.newForm2 = {
        regionName: '',
        remark: ''
      }
    },
    // 修改提交
    submit () {
      this.$emit('qyXg1', this.newForm2)
      this.$emit('update:Visible', false)
    }
  }
}
</script>
<style lang="less" scoped>
/deep/.el-dialog {
    position: relative;
    margin: 0 auto 50px;
    background: #fff;
    border-radius: 12px;
    box-sizing: border-box;
    width: 50%;
    .el-dialog__title {
      font-size: 18px;
      font-weight: 900;
      color: #333;
    }
    .el-dialog__body {
      padding: 20px 20px 0;

    }
    .el-form-item {
      display: flex;
      align-items: center;

      .el-form-item__content {
        margin-left: 0 !important;
      }

      .el-form-item__label {
        margin-left: 20px;
      }
      .el-input__inner {
        width: 396px;
        height: 36px;
      color: #333;

      }
      .el-textarea__inner {
        width: 396px;
        height: 82px;
      color: #333;

      }
    }
    .el-dialog__footer {
      margin-top: 0;
      text-align: center;
      .el-button {
        padding: 0;
        margin-right: 20px;
        width: 80px;
        height: 36px;
      }
      .noBtn {
        border-color: #f3e7e1;
        background-color: #f3e7e1;
        color: #333;
      }
      .yesBtn {
        border-color: #ff5e20;
        background-color: #ff5e20;
      }
    }
  }
</style>
